package com.etc.demo1.demo.mapper;

import com.etc.demo1.demo.domain.Goods;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface GoodsMapper {

    //查询全部
    @Select("select * from goods")
    List<Goods> findAll();

    //新增数据
    @Insert("INSERT INTO goods(goods.good_type,goods.good_name,goods.good_price,goods.good_product,goods.good_number) VALUES(#{goodtype},#{goodname},#{goodprice},#{goodproduct},#{goodnumber})")
    public int save(Goods goods);

    //删除数据
    @Delete("delete from goods where goods_id=#{id}")
    public int delete(int id);

    //根据id查找
    @Select("select * from goods where good_id=#{id}")
    public Goods getById(int id);

    //更新数据
    @Update("update goods set good_type=#{goodtype},good_name=#{goodname},good_price=#{goodprice},good_product=#{goodproduct},good_number=#{goodnumber} where good_id=#{goodid}")
    public int update(Goods goods);

}
